package com.cheer.controller;

import com.cheer.common.Result;
import com.cheer.param.ResourceParam;
import com.cheer.service.LecResourceService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.multipart.MultipartFile;

/**
 * @author cheer
 */
@RestController
@RequestMapping("/resource")
@Slf4j
public class LecResourceController {

    @Autowired
    private LecResourceService lecResourceService;


    @PostMapping("/upload")
    public Result upload(MultipartFile file, String type) {

        ResourceParam resourceParam = new ResourceParam();
        resourceParam.setFile(file);
        resourceParam.setType(type);
        String fileName = lecResourceService.upload(resourceParam);
        return Result.success(fileName);
    }

}
